package com.lazy.book.service.system.impl;

import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.lazy.book.mapper.system.SysTempFileHistoryMapper;
import com.lazy.book.pojo.system.pojo.dto.systempfile.SysTempFileHistoryCreateDTO;
import com.lazy.book.pojo.system.pojo.po.SysTempFileHistory;
import com.lazy.book.service.system.SysTempFileHistoryService;
import com.sz.core.util.BeanCopyUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author lay
 * @since 2025-09-05
 */
@Service
@RequiredArgsConstructor
public class SysTempFileHistoryServiceImpl extends ServiceImpl<SysTempFileHistoryMapper, SysTempFileHistory> implements SysTempFileHistoryService {

    private final SysTempFileHistoryMapper sysTempFileHistoryMapper;

    @Override
    public void create(SysTempFileHistoryCreateDTO dto) {
        SysTempFileHistory sysTempFileHistory = BeanCopyUtils.copy(dto, SysTempFileHistory.class);
        sysTempFileHistoryMapper.insert(sysTempFileHistory);
    }

    @Override
    public PageResult<SysTempFileHistory> historyList(SysTempFileHistoryListDTO dto) {
        QueryWrapper wrapper = QueryWrapper.create().where(SYS_TEMP_FILE_HISTORY.SYS_TEMP_FILE_ID.eq(dto.getSysTempFileId()));
        Page<SysTempFileHistory> page = page(PageUtils.getPage(dto), wrapper);
        return PageUtils.getPageResult(page);
    }

}